#ifndef _battery_dragonball_
#define _battery_dragonball_

#include "battery.h"
#include "igslib_iserial_manager.h"
#include "protocol_DragonBall.h"

namespace igslib
{
    class battery_Grgn:public CBattery
    { 
        protected:
            static int ID;
			int LocID;
        public:
            battery_Grgn()
            {
                ID++;
				LocID=ID;
                spi = nullptr;
            }

            ~battery_Grgn()
			{
				if(ID>-1)
				 ID--;
			}
             void SetSPI(ISpi* value) { spi = value; BATenable();}
			 float GetCapacity()
            {
                Protocol_DragonBall* tmp = (Protocol_DragonBall*)(spi);
				capacity=tmp->GetBatteryNV(LocID);
				return capacity;
            }
			
			void BATenable() 
			{
				  Protocol_DragonBall* tmp = (Protocol_DragonBall*)(spi);
				  tmp-> SetupBattery(LocID,1);
			}
    };
    int battery_Grgn::ID = -1;
};

#endif
